#!/bin/bash
#get current SVN tag if updating
CurrTag=`svn ls http://crystalhd-for-osx.googlecode.com/svn/tags | tail -n 1 | tr -d "/"`
#filter to version num only
LVerNum=`svn ls http://crystalhd-for-osx.googlecode.com/svn/tags | tail -n 1 | tr -d "abcdefghijlmnaopqrstuvwxyz./-"`
#get version on distro
UVerNum=`cat /home/atv/scripts/crystalnum`
#compare with current version num
if [ "$UVerNum" -lt "$LVerNum" ] ; then
echo "New CrystalHD version $LVerNum is available"
echo Checking out latest tag
mkdir chd
cd chd
svn checkout http://crystalhd-for-osx.googlecode.com/svn/tags/"$CurrTag"
echo Compiling lib
cd "$CurrTag"/crystalhd/linux_lib/libcrystalhd
make
sudo make install
echo Compiling driver
cd ../../driver/linux
autoconf
./configure
make
sudo make install
sudo modprobe crystalhd
cd /home/atv
echo Cleaning up directory
sudo rm -rf /home/atv/scripts/chd
echo Updating versioning file
echo "$LVerNum" > /home/atv/scripts/crystalnum
echo Installation complete. Now running: $LVerNum
else
echo "CrystalHD stable version is up-to-date: $UVerNum"
fi
